// window.onload = function () {
//     var url = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc76382e21021363b&redirect_uri=http://pay.capsui.com/base.do&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect';
//     var oBtn = document.getElementById('dashang');
//     oBtn.attachEvent('onclick', function () {
//         window.location.href = url;
//     });
// }

var isWx = false;
$(function () {
    if(document.getElementById("dashang")){
        return;
    }else{
        var $btn = $('<button id="dashang" style=" border: 1px solid transparent; padding: 6px 12px; line-height: 1.42857;  border-radius: 4px;  -moz-user-select: none;  -ms-user-select: none;  font-size: 16px; color: #fff;  background-color: #ea6f5a; left: 37%; position: relative;" onclick="dashang();">赞赏支持</button>');
        if (typeof WeixinJSBridge == "undefined") {
            $('.content').append($btn.css("left","45%"));
            isWx =false;
            $('head').append($('<script src="http://wx2.hsxyedu.com/js/layer/layer.js"></script>>'));
        }else{
            $('.news_article').append($btn);
            isWx = true;
        }
    }
});

function dashang () {
    if(isWx){
        var url = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc76382e21021363b&redirect_uri=http://wx2.hsxyedu.com/base.do&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect';
        window.location.href = url;
    } else{

    }
};